﻿using System.ComponentModel;
using System.Reflection;

namespace Borg
{
    public abstract class RepositoryElement : INotifyPropertyChanged
    {
        internal int id;

        public event PropertyChangedEventHandler PropertyChanged;

        public abstract string Name { get; }

        public abstract Assembly Assembly { get; }

        public int Id
        {
            get { return id; }
        }

        public bool IsReflectionOnly
        {
            get { return Assembly.ReflectionOnly; }
        }

        internal void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged == null)
                return;

            Runtime.InvokeEventHandler(
                "PropertyChanged",
                PropertyChanged,
                this,
                new PropertyChangedEventArgs(propertyName));
        }

        public override string ToString()
        {
            return string.Format("{0}{{{1}:{2}}}", GetType().Name, id, Name);
        }
    }
}

